package com.sunyard.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.sunyard.demo.mapper.UserMapper;
import com.sunyard.demo.po.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author zyl
 * @description
 * @since 2025/6/23
 */
@Service
public class UserService {

    @Resource
    private UserMapper userMapper;
    public User getUser() {
//        User user = userMapper.selectById(2);
//        System.out.println( user);
//
//        userMapper.update(null,new LambdaUpdateWrapper<User>()
//                .set(User::getPwd, "123456")
//                .eq(User::getId, 2));
//
//        userMapper.selectCount(null);
//
//        userMapper.selectList(new LambdaQueryWrapper<User>()
//                .orderByAsc(User::getId)
//                .orderByAsc(User::getName)
//        );
//
//        userMapper.selectList(new LambdaQueryWrapper<User>()
//                .eq(User::getId,1)
//                .eq(User::getName, "张三")
//                .eq(User::getIsDelete,0)
//                .or()
//                .isNull(User::getId)
//                .orderByAsc(User::getName)
//        );
//
//        userMapper.selectList(new LambdaQueryWrapper<User>()
//                .eq(User::getId,1)
//                .eq(User::getName, "张三")
//                .or()
//                .isNull(User::getId)
//                .orderByAsc(User::getName)
//        );
        User user1 = new User();
        user1.setId(1);
        List<String> strings = new ArrayList<>();
        strings.add("zss");
        user1.setNames(strings);
        user1.setPwd("11");
        userMapper.selectListById(user1);

        userMapper.selectListById2((long) user1.getId(),user1.getNames());

        userMapper.selectListById3(user1,user1.getNames());
        userMapper.selectListById4(new LambdaUpdateWrapper< User>()
                .eq(User::getId,user1.getId()));
        return null;
    }

    public static void main(String[] args) {
        List<Long> list = new ArrayList<>();
        list.add(1L);
        list.add(2L);
        list.add(3L);
        List<Long> list1 = new ArrayList<>();
        list1.add(1L);
        list1.add(4L);
        list1.add(5L);
        Set<Long> set = new HashSet<>(list1);
        boolean hasCommonElements = list.stream().anyMatch(set::contains);
        System.out.println(hasCommonElements);
        System.out.println(list1);
        System.out.println(list);
    }
}
